strike the right note
Say or do what is especially appropriate, as in
She struck the right note when she complimented the new parents on their baby
. This expression alludes to playing the correct note on an instrument.